# Maintainer: David Runge <dvzrv@archlinux.org>

_name=mailmanclient
pkgname=python-mailmanclient
pkgver=3.3.5
pkgrel=2
pkgdesc="Official Python bindings for the GNU Mailman 3 REST API"
arch=(any)
url="https://gitlab.com/mailman/mailmanclient"
license=(LGPL3)
depends=(python-requests python-typing-extensions)
makedepends=(python-build python-installer python-setuptools python-wheel)
checkdepends=(mailman3 python-falcon python-httpx python-pytest python-pytest-asyncio
python-pytest-services)
source=(https://files.pythonhosted.org/packages/source/${_name::1}/$_name/$_name-$pkgver.tar.gz{,.asc})
sha512sums=('42e1a30e7bbaeb57745cde116d441aafa4941e145429b1117993c24fd8fbd3e35d797e36f331e00a37e8c931fc44621c8103cc927b5bb1da0a273872c96c86c8'
            'SKIP')
b2sums=('9797e1de76e7beda42d2d559bb496ad6d8c87b0118749539c2a48ef999668d62ea96db4941174b6a8639a44df2b7d1e9fdc436b20b19a1deba458f74190e6191'
        'SKIP')
validpgpkeys=('541EA0448453394FF77A0ECC9D9B2BA061D0A67C') # Abhilash Raj <raj.abhilash1@gmail.com>

build() {
  cd $_name-$pkgver
  python -m build --wheel --no-isolation
}

check() {
  cd $_name-$pkgver
  pytest -v -k 'not using.rst and not test_find_user_page and not test_find_users'
}

package() {
  local site_packages=$(python -c "import site; print(site.getsitepackages()[0])")

  cd $_name-$pkgver
  python -m installer --destdir="$pkgdir" dist/*.whl
  # remove tests
  rm -frv "$pkgdir/$site_packages/$_name/tests/"
  find "$pkgdir/$site_packages/" -type f -iname "*conftest.py" -delete
  install -vDm 644 README.rst -t "${pkgdir}/usr/share/doc/${pkgname}"
}
